package com.zone.demo.controller;
import com.zone.demo.dto.Account;
import com.zone.demo.service.UserService;
import com.zone.demo.util.JsonResult;
import com.zone.demo.util.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: SJP
 * Date: 2021/7/8
 * Time: 16:25
 * Description: No Description
 * @author SJP
 */
@RestController
public class UserController {

   private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping(value = "/getAmountByName")
    public JsonResult getAmountByName(String name) {
       Account account = this.userService.getAmountByName(name);
       return new JsonResult(ResultCode.SUCCESS, account);
    }
    @GetMapping(value = "/createTableUser")
    public JsonResult createTableUser() {
        this.userService.createTableUser();
        return new JsonResult(ResultCode.SUCCESS);
    }
    @GetMapping(value = "/insertDataToUser")
    public JsonResult insertDataToUser() {

        this.userService.insertDataToUser();
        return new JsonResult(ResultCode.SUCCESS);
    }
    @GetMapping(value = "/createTableAccount")
    public JsonResult createTableAccount() {
        this.userService.createTableAccount();
        return new JsonResult(ResultCode.SUCCESS);
    }
    @GetMapping(value = "/insertDataToAccount")
    public JsonResult insertDataToAccount() {
        this.userService.insertDataToAccount();
        return new JsonResult(ResultCode.SUCCESS);
    }
}
